package com.hzmall.controller.backend;

import com.hzmall.common.ServerResponse;
import com.hzmall.service.impl.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/manage/category/")
public class CategoryBackendController {

    @Autowired
    private CategoryService categoryService;
    //获取品类子节点
    @RequestMapping(value = "get_category.do")
    @ResponseBody
    public ServerResponse category(Integer categoryId){
        return this.categoryService.category(categoryId);
    }

    //获取品类子节点及子节点
    @RequestMapping(value = "get_deep_category.do")
    @ResponseBody
    public ServerResponse deepCategory(Integer categoryId){
        return this.categoryService.deepCategory(categoryId);
    }

    //增加品类
    @RequestMapping(value = "add_category.do")
    @ResponseBody
    public ServerResponse addCategory(Integer parentId,String categoryName){
        return this.categoryService.addCategory(parentId, categoryName);
    }

    //修改品类名称
    @RequestMapping(value = "set_category_name.do")
    @ResponseBody
    public ServerResponse setCategoryName(Integer categoryId,String categoryName){
        return this.categoryService.setCategoryName(categoryId,categoryName);
    }
}
